package com.scetop.bank;

public class Account {
    private double balance;

    public Account(double init_balance){
        this.balance = init_balance;
    }

    public double getBalance(){
        return this.balance;
    }

    public boolean deposit(double amount){
        if (amount > 0){
            balance += amount;
            return true;
        }else{
            System.out.println("输入的数额少于0");
            return false;
        }
    }
    public boolean withdraw(double amt){
        if (amt > 0 && amt <= balance ){
            balance -= amt;
            return true;
        }else{
            System.out.println("输入的取款金额为负数或者余额不足");
            return false;
        }
    }

    // 提供一个受保护的 setBalance 方法
    protected void setBalance(double balance) {
        this.balance = balance;
    }
}